package org.neusoft.controller;

import org.neusoft.dto.UserLogin;
import org.neusoft.dto.UserReg;
import org.neusoft.entity.Tags;
import org.neusoft.entity.Users;
import org.neusoft.mapper.UserMapper;
import org.neusoft.rsp.ApiResponse;
import org.neusoft.service.IUserService;
import org.neusoft.vo.UserInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @AUTHOR 尹书岿
 * @DATE 2024/12/18 16:24
 * @DESCRIBE
 */
@RestController
@RequestMapping("/api")
public class UserController {
    @Autowired
    IUserService iUserService;
    @Autowired
    UserMapper userMapper;

    @PostMapping("/users")
    public ApiResponse<UserInfo> register(@RequestBody UserReg userReg){
        UserInfo userInfo = iUserService.register(userReg);
        return ApiResponse.success(userInfo);
    }
    @PostMapping("/users/login")
    public UserInfo login(@RequestBody UserLogin userLogin){
        return iUserService.login(userLogin);
    }

    //GET /api/user
    @GetMapping("/user")
    List<Users> getNowUser(){
        List<Users> users = userMapper.getCurrentUserList();
        return users;
    }

}
